package com.pc.scrs.service.impl;

import com.pc.scrs.bean.po.Subject;
import com.pc.scrs.bean.vo.SubjectVo;
import com.pc.scrs.dao.SubjectDao;
import com.pc.scrs.service.ISubjectService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
@Transactional
public class SubjectService implements ISubjectService {

    @Resource
    private SubjectDao subjectDao;

    @Override
    public List<SubjectVo> subjectList() {
        List<Subject> subjectList = subjectDao.querySubjectList();
        List<SubjectVo> subjectVoList = new ArrayList<>();
        for (Subject subject : subjectList) {
            SubjectVo subjectVo = new SubjectVo();
            subjectVo.setId(subject.getId());
            subjectVo.setTitle(subject.getTitle());
            subjectVoList.add(subjectVo);
        }
        return subjectVoList;
    }
}
